package cn.tedu.project.oa.assessProject.controller;

import cn.tedu.project.oa.assessProject.pojo.entity.LevelMode;
import cn.tedu.project.oa.assessProject.service.ILevelModeService;
import cn.tedu.project.oa.base.response.JsonResult;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/oa/assess/level")
@Api(tags = "13.等级制度")
public class LevelModeController {
    @Autowired
    private ILevelModeService levelModeService;

    /**
     * 查询等级制度列表
     */
    @GetMapping("/list")
    public JsonResult list(LevelMode levelMode)
    {
        List<LevelMode> list = levelModeService.selectLevelModeList(levelMode);
        return JsonResult.ok(list);
    }

//    /**
//     * 导出等级制度列表
//     */
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, LevelMode levelMode)
//    {
//        List<LevelMode> list = levelModeService.selectLevelModeList(levelMode);
//        ExcelUtil<LevelMode> util = new ExcelUtil<LevelMode>(LevelMode.class);
//        util.exportExcel(response, list, "等级制度数据");
//    }

    /**
     * 获取等级制度详细信息
     */
    @GetMapping(value = "/{id}")
    public JsonResult getInfo(@PathVariable("id") Long id)
    {
        return JsonResult.ok(levelModeService.selectLevelModeById(id));
    }

    /**
     * 新增等级制度
     */
    @PostMapping
    public JsonResult add(@RequestBody LevelMode levelMode)
    {
        return JsonResult.ok(levelModeService.insertLevelMode(levelMode));
    }

    /**
     * 修改等级制度
     */
    @PutMapping
    public JsonResult edit(@RequestBody LevelMode levelMode)
    {
        return JsonResult.ok(levelModeService.updateLevelMode(levelMode));
    }

    /**
     * 删除等级制度
     */
    @DeleteMapping("/{ids}")
    public JsonResult remove(@PathVariable Long[] ids)
    {
        return JsonResult.ok(levelModeService.deleteLevelModeByIds(ids));
    }
}
